package com.meetingshow.meeting.service;

import java.util.ArrayList;
import java.util.List;

import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseServiceImp;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.meeting.dao.TopicDAO;
import com.meetingshow.meeting.dao.model.TopicPO;
import com.meetingshow.meeting.service.model.TopicQueryParas;
import com.meetingshow.meeting.service.util.TopicQueryParasBuilder;
import com.meetingshow.meeting.service.util.TopicServiceParas;

public class TopicServiceImp extends BaseServiceImp implements ITopicService {

    private TopicDAO topicDAO;
    
    /**
     * @return the topicDAO
     */
    public TopicDAO getTopicDAO() {
        return topicDAO;
    }

    /**
     * @param topicDAO the topicDAO to set
     */
    public void setTopicDAO(TopicDAO topicDAO) {
        this.topicDAO = topicDAO;
    }

    @Override
    public Integer saveTopic(TopicPO topicPO) throws Exception {
        return getTopicDAO().saveTopic(topicPO);
    }

    @Override
    public void updateTopic(TopicPO topicPO) throws Exception {
        getTopicDAO().updateTopic(topicPO);
    }

    @Override
    public void removeTopic(TopicPO topicPO) throws Exception {
        getTopicDAO().removeTopic(topicPO);
    }
    
    @Override
    public TopicPO loadTopicById(Integer topicId) throws Exception {
        return getTopicDAO().loadTopicById(topicId);
    }

    @Override
    public QueryResults<TopicPO> queryTopic(
            TopicQueryParas topicQueryParas) throws Exception {
        QueryStruct queryStruct = new QueryStruct();
        List<String> tableList = new ArrayList<String>();
        List<String> returnObjectList = new ArrayList<String>();
        
        tableList.add(TopicServiceParas.TOPIC_PO);
        returnObjectList.add(TopicServiceParas.TOPIC_PO);
        
        queryStruct.setTableList(tableList);
        queryStruct.setReturnObjectList(returnObjectList);
        
        queryStruct = TopicQueryParasBuilder.topicQueryBuilder(queryStruct, topicQueryParas);
        QueryResults<TopicPO> queryResults = getTopicDAO().queryTopic(queryStruct);
        return queryResults;
    }

}
